
public class Camera {
	public static Vector3D pos;
    float yaw, pitch;
    static float PLAYER_SPEED;
    boolean goa, gos, god, gow;
    
    
    public Camera(){
    	PLAYER_SPEED = 0.3f;
    	pos=new Vector3D(144,122,44);
    	goa=gos=god=gow=false;
    	yaw=-2.65f;
    	pitch=-0.16f;
    }
    
    public void cameraRun(){
    	if(PLAYER_SPEED == 1.0f && MyJoglCanvas.perspective > 45f) {
    		MyJoglCanvas.perspective-=0.1f;
    		MyJoglCanvas.radius/=1.003f;
    		MyJoglCanvas.blur -= 0.006f;
    	}
    	if(PLAYER_SPEED == 3.0f && MyJoglCanvas.perspective < 50f && (goa||god||gow||gos)) {
    		MyJoglCanvas.perspective++;
    		MyJoglCanvas.radius*=Math.pow(1.003,10);
    		MyJoglCanvas.blur += 0.06f;
    	}
    	    if(gow){
    	    	float pre_x = pos.x()+(float)Math.cos(yaw)*(float)Math.cos(pitch)*PLAYER_SPEED;
    	    	float pre_y = pos.y()+(float)Math.sin(yaw)*(float)Math.cos(pitch)*PLAYER_SPEED;
    	    	boolean set_x = false;
    	    	boolean set_y = false;
    	    	if(Ground.hmap_height(pre_x,pos.y) > 0.0 && Ground.hmap_height(pre_x,pos.y) < 3.0) set_x = true; 
    	    	if(Ground.hmap_height(pos.x,pre_y) > 0.0 && Ground.hmap_height(pos.x,pre_y) < 3.0) set_y = true;
    	    	if(set_x)pos.setX(pre_x);
    	    	if(set_y)pos.setY(pre_y);
    	    }
    	    if(gos){
    	    	float pre_x = pos.x()-(float)Math.cos(yaw)*(float)Math.cos(pitch)*PLAYER_SPEED;
    	    	float pre_y = pos.y()-(float)Math.sin(yaw)*(float)Math.cos(pitch)*PLAYER_SPEED;
    	    	boolean set_x = false;
    	    	boolean set_y = false;
    	    	if(Ground.hmap_height(pre_x,pos.y) > 0.0 && Ground.hmap_height(pre_x,pos.y) < 3.0) set_x = true; 
    	    	if(Ground.hmap_height(pos.x,pre_y) > 0.0 && Ground.hmap_height(pos.x,pre_y) < 3.0) set_y = true;
    	    	if(set_x)pos.setX(pre_x);
    	    	if(set_y)pos.setY(pre_y);
    	    }
    	    if(goa){
    	    	float pre_x = pos.x()-(float)Math.sin(yaw)*PLAYER_SPEED;
    	    	float pre_y = pos.y()+(float)Math.cos(yaw)*PLAYER_SPEED;
    	    	boolean set_x = false;
    	    	boolean set_y = false;
    	    	if(Ground.hmap_height(pre_x,pos.y) > 0.0 && Ground.hmap_height(pre_x,pos.y) < 3.0) set_x = true; 
    	    	if(Ground.hmap_height(pos.x,pre_y) > 0.0 && Ground.hmap_height(pos.x,pre_y) < 3.0) set_y = true;
    	    	if(set_x)pos.setX(pre_x);
    	    	if(set_y)pos.setY(pre_y);
    	    }
    	    if(god){
    	    	float pre_x = pos.x()+(float)Math.sin(yaw)*PLAYER_SPEED;
    	    	float pre_y = pos.y()-(float)Math.cos(yaw)*PLAYER_SPEED;
    	    	boolean set_x = false;
    	    	boolean set_y = false;
    	    	if(Ground.hmap_height(pre_x,pos.y) > 0.0 && Ground.hmap_height(pre_x,pos.y) < 3.0) set_x = true; 
    	    	if(Ground.hmap_height(pos.x,pre_y) > 0.0 && Ground.hmap_height(pos.x,pre_y) < 3.0) set_y = true;
    	    	if(set_x)pos.setX(pre_x);
    	    	if(set_y)pos.setY(pre_y);
    	    }
    	    pos.setZ(Ground.hmap_height(pos.x,pos.y)+6.0f);
    	 //   System.out.println(Ground.hmap_height(pos.x,pos.y));
    	    
    }
    
}
